home *** CD-ROM | disk | FTP | other *** search
- /*
- File: ComponentDispatch.c
-
- Contains: Common routines for dispatching for any sound component
-
- Written by: Mark Cookson
-
- Copyright: Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 8/16/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
-
- #ifndef __COMPONENTDISPATCH__
- #include "ComponentDispatch.h"
- #endif
-
- #define DEBUG false
-
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- // Sound Component Entry Point
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-
- #if GENERATINGPOWERPC
- ProcInfoType __procinfo=uppSoundComponentEntryPointProcInfo;
- #endif
- pascal ComponentResult main(ComponentParameters *params, SoundComponentGlobalsPtr globals)
- {
- ComponentResult result;
- short selector = params->what;
-
- #if DEBUG
- DebugStr ("\pIn SoundComponentEntryPoint;g");
- #endif
-
- if (selector < 0)
- switch (selector - kComponentRegisterSelect) // standard component selectors
- {
- case kComponentRegisterSelect - kComponentRegisterSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __SoundComponentRegister);
- break;
-
- case kComponentVersionSelect - kComponentRegisterSelect:
- return (kSoundComponentVersion);
- break;
-
- case kComponentCanDoSelect - kComponentRegisterSelect:
- result = __SoundComponentCanDo(0, *((short *) ¶ms->params[0]));
- break;
-
- case kComponentCloseSelect - kComponentRegisterSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __SoundComponentClose);
- break;
-
- case kComponentOpenSelect - kComponentRegisterSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __SoundComponentOpen);
- break;
-
- default:
- result = badComponentSelector;
- break;
- }
- else if (selector < kDelegatedSoundComponentSelectors) // selectors that cannot be delegated
- switch (selector)
- {
- case kSoundComponentInitOutputDeviceSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __InitOutputDevice);
- break;
-
- default:
- result = badComponentSelector;
- break;
- }
- else // selectors that can be delegated
- switch (selector)
- {
- case kSoundComponentGetInfoSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __SoundComponentGetInfo);
- break;
-
- case kSoundComponentSetInfoSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __SoundComponentSetInfo);
- break;
-
- case kSoundComponentStartSourceSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __StartSource);
- break;
-
- case kSoundComponentPlaySourceBufferSelect:
- result = CallComponentFunctionWithStorageUniv((Handle) globals, params, __SoundComponentPlaySourceBuffer);
- break;
-
- default:
- result = DelegateComponentCall(params, globals->sourceComponent);
- break;
- }
-
- return (result);
- }
-
-
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- static pascal ComponentResult __SoundComponentCanDo(void *unused1, short selector)
- {
- #pragma unused (unused1)
-
- ComponentResult result;
-
- switch (selector)
- {
- case kComponentRegisterSelect:
- case kComponentVersionSelect:
- case kComponentCanDoSelect:
- case kComponentCloseSelect:
- case kComponentOpenSelect:
- case kSoundComponentInitOutputDeviceSelect:
- // selectors that can be delegated
- case kSoundComponentStartSourceSelect:
- case kSoundComponentGetInfoSelect:
- case kSoundComponentSetInfoSelect:
- case kSoundComponentPlaySourceBufferSelect:
- result = true;
- break;
-
- default:
- result = false;
- break;
- }
-
- return (result);
- }
-
-